#ifndef GLTEXTURE_H
#define GLTEXTURE_H

#if 0
//AngryGL
#include "mygl.h"
#include "../ut/UTImage.h"
#define GLTEX_LOADER_ENABLED
#else
//solo GLTexture
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#endif

#define GLTEX_REPEAT    0
#define GLTEX_EDGE	    1


class GLTexture
{
    public:
		GLTexture();
		GLTexture(int w, int h);
        virtual ~GLTexture();

		//constructors
		#ifdef GLTEX_LOADER_ENABLED
		static GLTexture* createFromFile(const char* filename, int flags);
		static GLTexture* createFromImage(const UTImage* img);
        #endif

		//gl actions
        inline void enable() const { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textureId); }
        inline void disable() const { glDisable(GL_TEXTURE_2D); }
		void drawBillboard(float x1, float y1, float x2, float y2);
        void drawBillboard(float w, float h) { drawBillboard(-w/2, -h/2, w/2, h/2); }
        void drawImage(float x1, float y1, float x2, float y2);
        void drawImage(float w, float h) { drawImage(-w/2, -h/2, w/2, h/2); }
        void update(void* data);

		//getters
		inline GLuint getTextureId() const { return textureId; }
		inline int getWidth() const { return width; }
		inline int getHeight() const { return height; }

    private:

        GLuint textureId;
        int width;
        int height;
        //String fileName;

        void buildColorTexture(unsigned char r, unsigned char g, unsigned char b);

};

#endif // GLTEXTURE_H
